package web.board.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import web.board.service.BoardServiceImpl;
import web.board.vo.RequestVo;


//import web.board.vo.RequestVo;

@Controller
@RequestMapping("/board")
public class BoardController{
	
	@Autowired
	private BoardServiceImpl boardService;
	
	
	@RequestMapping(value="/listAll", method=RequestMethod.GET)
	public ModelAndView selectBoardList(String requestString){
		ModelAndView mav = new ModelAndView();
		List<RequestVo> listObject = null;
		try{
			listObject = boardService.listAll();
		}catch(Exception e){
			e.printStackTrace();
		}
		
		mav.addObject("listObject", listObject);
		mav.addObject("returnMessage", requestString);
		mav.setViewName("board/selectBoardList");
		return mav;
	}
	
	@RequestMapping(value="/selectBoardContent", method=RequestMethod.GET)
	public ModelAndView selectBoardContent(String requestString){
		ModelAndView mav = new ModelAndView();
		RequestVo boardObject = null;
		try{
			boardObject = boardService.selectBoardContent();
		}catch(Exception e){
			e.printStackTrace();
		}
		
		mav.addObject("boardObject", boardObject);
		mav.addObject("returnMessage", requestString);
		mav.setViewName("board/selectBoardContent");
		return mav;
	}
}
